
var vm = new Vue({
    el:'#rrapp',
    data :{
        tableDatas:[],
        gridData: [],
        dialogTableVisible: false,
        queryByDate:[],
        colData: [
            {index: 0,  isShow: false},
            {index: 1,  isShow: false},
            {index: 2,  isShow: false},
            {index: 3,  isShow: false},
            {index: 4,  isShow: false},
            {index: 5,  isShow: false},
            {index: 6,  isShow: false},
            {index: 7,  isShow: false},
            {index: 8,  isShow: false},
            {index: 9,  isShow: false},
            {index: 10,  isShow: false}
        ],
    },
    mounted ()
    {
        this.getData();
    },
    methods: {

        getData: function () {
            $.get(baseURL + "fun/emp/changeStatisticsList", function (r) {
                vm.tableDatas = r.list;
            });
        },
        bccelldblclick: function (row, column, cell, event) {


            var currDate = moment(row.month);

            var date = new Date(currDate.startOf("month").valueOf())
            /* 将时间戳转换为日期格式*/
            var Y = date.getFullYear() + '-'
            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
            var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
            var date2 = new Date(currDate.endOf("month").valueOf())
            var Y1 = date2.getFullYear() + '-'
            var M1 = (date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1) + '-'
            var D1 = (date2.getDate() < 10 ? '0' + date2.getDate() : date2.getDate()) + ' '
            vm.queryByDate[0]=Y+M+D;
            vm.queryByDate[1]=Y1+M1+D1;
            vm.colData=[
                {index: 0,  isShow: false},
                {index: 1,  isShow: false},
                {index: 2,  isShow: false},
                {index: 3,  isShow: false},
                {index: 4,  isShow: false},
                {index: 5,  isShow: false},
                {index: 6,  isShow: false},
                {index: 7,  isShow: false},
                {index: 8,  isShow: false},
                {index: 9,  isShow: false},
                {index: 10,  isShow: false},
            ];
            switch (column.property) {
                case 'addEmp':
                    var url = "fun/emp/addList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart':vm.queryByDate[0],
                            'dateEnd':vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.colData[0].isShow=true;
                                vm.colData[1].isShow=true;
                               vm.gridData=r.page.list;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                    break;
                case 'changeDept':
                    var url = "fun/emp/changeDeptList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart': vm.queryByDate[0],'dateEnd': vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.gridData=r.page.list;
                                vm.colData[4].isShow=true;
                                vm.colData[5].isShow=true;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                break;
                case 'changeOffice':
                    var url = "fun/emp/changeOfficeList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart': vm.queryByDate[0],'dateEnd': vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.colData[0].isShow=true;
                                vm.colData[2].isShow=true;
                                vm.colData[3].isShow=true;
                                vm.gridData=r.page.list;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                    break;
                case 'removeEmp':
                    var url = "fun/emp/changeStatusList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart': vm.queryByDate[0],'dateEnd': vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.colData[0].isShow=true;
                                vm.colData[6].isShow=true;
                                vm.gridData=r.page.list;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });

                break;
                case 'changeExistEmp':
                    var url = "fun/emp/empChangeStatusExistList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart': vm.queryByDate[0],'dateEnd': vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.colData[0].isShow=true;
                                vm.colData[7].isShow=true;
                                vm.colData[8].isShow=true;
                                vm.colData[9].isShow=true;
                                vm.gridData=r.page.list;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });

                break;
                case 'changeNotEmp':
                    var url = "fun/emp/empChangeStatusNotList";
                    $.ajax({
                        type: "GET",
                        url: baseURL + url,
                        contentType: "application/json",
                        data: {'dateStart': vm.queryByDate[0],'dateEnd': vm.queryByDate[1]},
                        success: function(r){
                            if(r.code === 0){
                                vm.colData[0].isShow=true;
                                vm.colData[7].isShow=true;
                                vm.colData[8].isShow=true;
                                vm.colData[9].isShow=true;
                                vm.gridData=r.page.list;
                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                break;
            }
            vm.dialogTableVisible = true;
        }
    }
});
